<?
layout("/inc/win_layout.html",{title:sysTitle}){
?>
	<link rel="stylesheet" href="static/uploadify/uploadify.css" type="text/css"></link>
	<script type="text/javascript" src="static/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="static/utf8-jsp/ueditor.config.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/ueditor.all.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/third-party/video-js/video.js"></script>
	<script type="text/javascript" src="static/My97DatePicker/WdatePicker.js"></script>
<div id="page-wrapper" style="margin-left: 0px; ">

	<!--BEGIN CONTENT-->
	<div class="page-content"
		style="min-height: auto;padding-bottom: 20px; height: 610px; overflow: auto;">

		<div class="row mbl">
			<input id="balance" type="hidden" class="form-control" value="0" />
			<input id="payment" type="hidden" class="form-control" value="0" />
			<input id="createTime" type="hidden" class="form-control" value="" />
			<div class="panel">
				<div class="panel-body pan" overflow: auto;">

					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">用户名
								<span class='require' id="yonghu">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="membername" type="text" class="form-control" onchange="verifyName(this.value)" value="" />
								</div>
							</div>
						</div>
						<div id = "passwordParent" class="col-lg-6"
							style="width: 400px; float:left;margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">密码
								<span class='require' id="yonghu">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="memberpassword" type="password" class="form-control" value="" />
								</div>
							</div>
						</div>
					</div>

					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">真实姓名</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="realname" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">昵称
							</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="nickname" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
					</div>
                     
                      <div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px;display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">联系电话
								<span class='require'></span></label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="telephone" type="text" class="form-control" />
								</div>
							</div>
						</div>
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px;display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">手机号
								<span class='require'>*</span></label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="mobilephone" type="text" class="form-control" />
								</div>
							</div>
						</div>
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px;display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">用户类型</label>
							<div class="col-md-9">
								<div class="input-icon">
									<select id="type" class="form-control">
										<option value="0" selected>个人用户</option>
									</select>
								</div>
							</div>
						</div>
						<div class="col-lg-6" style="width: 400px; float:left;margin-right:-20px; display:inline;">
							<label for="firstname" class="col-md-3 control-label">邮箱
							</label>
							 <div class="col-md-9">
								<div class="input-icon">
									<input id="email" type="text" class="form-control" />
								</div>
							</div>
						</div>	
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">头像
							</label>
							<div class="col-md-9">
								<div>
									<div style="display:inline " id="single"></div>
									<input type="button" style="width: 70px;height: 30px;padding: 0;background-color: #4cae4c;border-color: #4cae4c;" class="btn btn-primary" onclick="upImages()" value="上传图片"  />
									<textarea id="uploadImage" name="uploadImage"></textarea>
									<input id="avatarImg" type="hidden" class="form-control" value="" />
								</div>
							</div>
						</div>
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">秘钥</label>
							<div class="col-md-9">
								<div class="input-group input-group-sm mbs">
									<input id="keys" type="text"  class="form-control" disabled="true" /> 
									<span class="input-group-btn">
									<button onclick="createKeys()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">生成秘钥</button>
									</span> 
								</div>
							</div>
					    </div>
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">专业</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="profession" class="form-control" />
								</div>
							</div>
						</div>
						<div class="col-lg-6" style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="firstname" class="col-md-3 control-label">地址
							</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="address" type="text" class="form-control" />
								</div>
							</div>
						</div>
					</div>
					<div class="row" style=" margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">证件类型
							</label>
							<div class="col-md-9">
								<div class="input-icon">
									<select id="certificateType" class="form-control">
										<option value="0">身份证</option>
										<option value="1">军官证</option>
										<option value="2">护照</option>
										<option value="3">其他</option>
									</select>
								</div>
							</div>
						</div>
						<div class="col-lg-6"
							style="width: 400px; float:left; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">证件号
							</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="certificateNumber" class="form-control" />
								</div>
							</div>
						</div>
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">工作单位</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="workunit" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
						<div class="col-lg-6"
							style="width: 400px;  float:left; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">职称
							</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="title" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">状态
								<span class='require'>*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<select id="status" class="form-control">
										<option value="0">启用</option>
										<option value="1">禁用</option>
									</select>
								</div>
							</div>
						</div>
						<div class="col-lg-6"
							style="width: 400px; float:left;  margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">学历</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="education" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left; margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">性别
								<span class='require'>*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<select id="gender" class="form-control">
										<option value="0">女</option>
										<option value="1">男</option>
										<option value="2">未知</option>
									</select>
								</div>
							</div>
						</div>
						<div class="col-lg-6"
							style="width: 400px; float:left;  margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">年龄
								<span class='require'>*</span></label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="age" type="text" class="form-control" value="" />
								</div>
							</div>
						</div>
					</div>
					<div style="margin-bottom: 10px; width: 750px;margin-right:-20px;">
						<label for="inputUsername" class="col-md-3 control-label">研究领域
							<span class='require'></span> </label>
						<div class="col-md-12">
							<div class="input-icon">
								<textarea id="researchField" rows="2" cols="20"
									class="form-control"></textarea>
							</div>
						</div>
					</div>
					<div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="width: 400px; float:left;  margin-right:-20px; display:inline;">
							<label for="inputUsername" class="col-md-3 control-label">有效期</label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="validity" type="text" class="form-control" value="" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" />
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--END CONTENT-->
</div>


<?} ?>
<script type="text/javascript">
	var index1 = window.parent.getlay();
	var _editor;
	$(function() {
		if (index1 != 0) {
			$("#passwordParent").hide();
			$.ajax({
				type : "post",
				url : "./memberUpdate.do",
				data : {
					"id" : index1,
				},
				dataType : "json",
				async : false,
				success : function(data) {
					$("#membername").val(data[0].username);
					$("#memberpassword").val(data[0].password);
					document.getElementById('memberpassword').disabled = true;
					$("#nickname").val(data[0].nickname);
					$("#realname").val(data[0].realname);
					$("#type").val(data[0].type);
					$("#createTime").val(data[0].createTime);
					$("#createIpAddress").val(data[0].createIpAddress);
					$("#avatarImg").val(data[0].avatarImg);
					$("#single").html("<img src='"+data[0].avatarImg+"' width='30' height='30'/>");
					$("#email").val(data[0].email);
					$("#education").val(data[0].education);
					$("#profession").val(data[0].profession);
					$("#researchField").val(data[0].researchField);
					$("#status").val(data[0].status);
					$("#mobilephone").val(data[0].mobilephone);
					$("#workunit").val(data[0].workunit);
					$("#title").val(data[0].title);
					$("#certificateType").val(data[0].certificateType);
					$("#certificateNumber").val(data[0].certificateNumber);
					$("#balance").val(data[0].balance);
					$("#payment").val(data[0].payment);
					$("#age").val(data[0].age);
					$("#gender").val(data[0].gender);
					$("#keys").val(data[0].keys);
					$("#address").val(data[0].address);
					$("#telephone").val(data[0].telephone);
					$("#validity").val(data[0].validity);
                    
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
		
		 _editor = UE.getEditor('uploadImage');
	    _editor.ready(function (){
	        //设置编辑器不可用(事实上不可以设置不可用...所以注释掉,以观后效)
	        _editor.setDisabled();
	        //隐藏编辑器,因为只使用上传功能
	        _editor.hide();
	        //侦听图片上传
	  	 	_editor.addListener('beforeInsertImage',function(t,arg){
	  	 			for(var i=0;i<arg.length;i++){
	  	 				var urlPath = arg[i].src;
	  	 				$("#avatarImg").val(urlPath);
						$("#single").html("<img src='"+urlPath+"' width='30' height='30' />");
	  	 			}
	        });
	        //侦听文件上传
		   	 _editor.addListener('afterUpfile',function(t,arg){
		   	 	
		   	 });
	   }); 
	});
 	//上传图片
	function upImages() {
		var myFiles = _editor.getDialog("insertimage");
	  		myFiles.open();
	   
	}
	function Page() {
		if ($.trim($("#membername").val()).length < 1) {
			alert('用户名不能为空！');
			return null;
		}
		if ($.trim($("#memberpassword").val()).length < 1 && index1 == 0) {
			alert('密码不能为空！');
			return null;
		}else{
			var reg =new RegExp("[\u4e00-\u9fa5]");
			if(reg.test($("#password").val())){
		      	alert('密码只可由数字和字母组成！');
				return null;
		    }
		}
		if ($.trim($("#mobilephone").val()).length < 1) {
			alert('手机号不能为空！');
			return null;
		}

		if ($.trim($("#status").val()).length < 1) {
			alert('请选择状态！');
			return null;
		}
		if ($.trim($("#age").val()).length < 1) {
			alert('请填写您的年龄！');
			return null;
		}
		/*
		if ($.trim($("#validity").val()).length < 1) {
			alert('请选择有效时间！');
			return null;
		}
		*/
		$.ajax({
			type : "post",
			url : "./userAddUpdate.do",
			data : {
				"id" : index1,
				"username" : $("#membername").val(),
				"password" : $("#memberpassword").val(),
				"nickname" : $("#nickname").val(),
				"realname" : $("#realname").val(),
				"mobilephone" : $("#mobilephone").val(),
				"createIpAddress" : $("#createIpAddress").val(),
				"email" : $("#email").val(),
				"avatarImg" : $("#avatarImg").val(),
				"createTime" : $("#createTime").val(),
				"status" : $("#status").val(),
				"education" : $("#education").val(),
				"profession" : $("#profession").val(),
				"researchField" : $("#researchField").val(),
				"workunit" : $("#workunit").val(),
				"title" : $("#title").val(),
				"certificateType" : $("#certificateType").val(),
				"certificateNumber" : $("#certificateNumber").val(),
				"type" : $("#type").val(),
				"balance" : $("#balance").val(),
				"payment" : $("#payment").val(),
				"age" : $("#age").val(),
				"gender" : $("#gender").val(),
				"keys":$("#keys").val(),
				"address":$("#address").val(),
				"telephone":$("#telephone").val(),
				"validity":$("#validity").val(),
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.get();
				parent.layer.msg('提交成功');
				parent.layer.close(index);
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
	function newdate() {
		$.getJSON('./newDate.do', {}, function(res) {
			$("#createTime").val(res.date);
		});
	};
	
	function createKeys(){
		$.ajax({
			type : "post",
			url : "createKeys.do",
			dataType : "json",
			success : function(data) {
				$("#keys").val(data[0].keys);
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
 //验证用户名是否重复
 function verifyName(memberName){
	$.ajax({
		type : "post",
		url : "verifyMemberName.do",
		data : {
			"memberName" : memberName,
			"type" : 0,
		},
		async : false,
		dataType : "json",
		success : function(data) {
			if(data[0].count != '0'){
				$("#membername").val("");
				layer.msg('用户名已存在!请重新输入！');
			}
		},
		error : function(data) {
			alert("请求失败");
		}
	});
 }
</script>